
$(function(){
	
	$("#container").fadeIn(500 , function(){
		
		bannerAnim()
	})
	/* setTimeout(function(){
		bannerAnim()
	},500) */
	
	function bannerAnim(){
	TweenMax.staggerFromTo(".pic1", 1.3, {
					  cycle:{
						
						opacity:function(i){
							return 0;
							},
						scale:function(i){
						  return 0.5;
						}
					  }
					},
					  
					 {
					  cycle:{
						
						opacity:function(i){
							return 1;
							},
						scale:function(i){  
						 return 1;
						},
						ease:function (i){
							return  Back.easeOut.config(4); //Back.easeOut.config(10); 缓动 10个像素
							}
					  }
					  
					,onComplete:function (){
						
						}}, 0.25)
		
	   
	  
	  
				
				
	}
	
	
	
	$(".tab1btn").click(function(e){
		e.preventDefault();
		var tabIndex = $(this).index();
		console.log(tabIndex)
		$(".tab1btn").eq(tabIndex).find(".tab1-pic1").css({display:"none"})
		$(".tab1btn").eq(tabIndex).find(".tab1Active").css({display:"block"})
		
		$(".tab1btn").eq(tabIndex).siblings().find(".tab1-pic1").css({display:"block"})
		$(".tab1btn").eq(tabIndex).siblings().find(".tab1Active").css({display:"none"})
		
		$(".tab1-txt").eq(tabIndex).css({display:"block"})
		$(".tab1-txt").eq(tabIndex).siblings().css({display:"none"})
		
		
		
	})
	
	
	$(".tab2btnbox").click(function(e){
		e.preventDefault();
		var tabIndex2 = $(this).index();
		console.log(tabIndex2)
		$(".tab2btnbox").eq(tabIndex2).find(".tab2-txtbg").css({display:"none"})
		$(".tab2btnbox").eq(tabIndex2).find(".tab2-txtact").css({display:"block"})
		
		$(".tab2btnbox").eq(tabIndex2).siblings().find(".tab2-txtbg").css({display:"block"})
		$(".tab2btnbox").eq(tabIndex2).siblings().find(".tab2-txtact").css({display:"none"})
		
		var bgleft = tabIndex2==1? "50%":"0" 
		
		$(".tab2bgact").css({left:bgleft})
		
		$(".tab2txtpic").eq(tabIndex2).css({display:"block"})
		$(".tab2txtpic").eq(tabIndex2).siblings().css({display:"none"})
		
		
	})
	
	
	
	
	//页面滚动事件
	var winH = $(window).height();
	
	
	$(window).resize(function(){
		setTimeout(function(){
			winH = $(window).height();
		},250)
	})
	
	
	
	var anim01 = document.getElementById("anim01");
	anim01.play=false;
	
	var anim02 = document.getElementById("ptjgbox");
	anim02.play=false;
	
	var anim03 = document.getElementById("jjfabox");
	anim03.play=false;
	
	var anim04 = document.getElementById("animtxt");
	anim04.play=false;
	
	var animl5 = document.getElementById("line5row");
	animl5.play=false;
	
	var quanelm = document.getElementById("quananim");
	quanelm.play=false;
	
	
	$(window).scroll(function() {
		
		//console.log("123")
		animfn01(anim01)
		
		animfn02(anim02)
		
		animfn03(anim03)
		
		quananim(quanelm)
		
		line5fn(animl5)
		
		animfn04(anim04)
		
		
		
	})
	
	
	function animfn01(elm){ // 核心优势
		var animTop01 = getElemTop(elm);
		//console.log(animTop01)
		if(animTop01<winH*0.7 && !elm.play){
			elm.play=true;
	
			TweenMax.to(".hxys1",0.6,{x:0,ease:Back.easeOut.config(1),repeat:0})
			TweenMax.to(".hxys2",0.6,{x:0,ease:Back.easeOut.config(1),repeat:0,delay:0.4})
			TweenMax.to(".hxys3",0.6,{x:0,ease:Back.easeOut.config(1),repeat:0,delay:0.8})
			TweenMax.to(".hxys4",0.6,{x:0,ease:Back.easeOut.config(1),repeat:0,delay:1.2})
			TweenMax.to(".hxys5",0.6,{x:0,ease:Back.easeOut.config(1),repeat:0,delay:1.6})
			TweenMax.to(".hxys6",0.6,{x:0,ease:Back.easeOut.config(1),repeat:0,delay:2})
			//$(".hxys1").css({transform:"translate3D(0,0,0)"});
			
			/*$(".hxys2").css({transform:"translate3D(0,0,0)"});
			$(".hxys3").css({transform:"translate3D(0,0,0)"});
			$(".hxys4").css({transform:"translate3D(0,0,0)"});
			$(".hxys5").css({transform:"translate3D(0,0,0)"});
			$(".hxys6").css({transform:"translate3D(0,0,0)"});*/
			
			/*setTimeout(function(){ $(".hxys2").css({transform:"translate3D(0,0,0)"}); },400)
			setTimeout(function(){ $(".hxys3").css({transform:"translate3D(0,0,0)"}); },800)
			setTimeout(function(){ $(".hxys4").css({transform:"translate3D(0,0,0)"}); },1200)
			setTimeout(function(){ $(".hxys5").css({transform:"translate3D(0,0,0)"}); },1600)
			setTimeout(function(){ $(".hxys6").css({transform:"translate3D(0,0,0)"}); },2000)*/
			
		}
	}
	
	
	
	
	function animfn02(elm){ // 平台架构
		var animTop02 = getElemTop(elm);
		
		if(animTop02<winH*0.7 && !elm.play){
			elm.play=true;
			TweenMax.staggerFromTo(".ptjgt3", 0.5, {
						  cycle:{
							
							opacity:function(i){
								return 0;
								},
							y:function(i){
							  return 10;
							}
						  }
						},
						  
						 {
						  cycle:{
							
							opacity:function(i){
								return 1;
								},
							y:function(i){  
							 return 0;
							},
							ease:function (i){
								return  Back.easeOut.config(0); //Back.easeOut.config(10); 缓动 10个像素
								}
						  }
						  
						,onComplete:function (){
							
							}}, 0.5)
					
			}		
				
	}
	
	function animfn03(elm){ // 解决方案
		var animTop03 = getElemTop(elm);
		
		if(animTop03<winH*0.7 && !elm.play){
			elm.play=true;
			/*TweenMax.to(".jjfa3-1",2,{opacity:1,y:0,ease:Back.easeOut.config(0),repeat:0,delay:0})
			TweenMax.to(".jjfa3-2",1,{opacity:1,y:0,ease:Back.easeOut.config(0),repeat:0,delay:0.15})
			TweenMax.to(".jjfa3-3",1,{opacity:1,y:0,ease:Back.easeOut.config(0),repeat:0,delay:0.3})*/
			TweenMax.staggerFromTo(".jjfa3", 2, {
						  cycle:{
							
							opacity:function(i){
								return 0;
								},
							y:function(i){
							  return -20;
							}
						  }
						},
						  
						 {
						  cycle:{
							
							opacity:function(i){
								return 1;
								},
							y:function(i){  
							 return 0;
							},
							ease:function (i){
								return  Back.easeOut.config(0); //Back.easeOut.config(10); 缓动 10个像素
								}
						  }
						  
						,onComplete:function (){
							
							}}, 0.5)
					
			}		
				
	}
	
	
	
	function line5fn(elm){ // 解决方案
		var animTopl5 = getElemTop(elm);
		
		if(animTopl5<winH*0.7 && !elm.play){
			elm.play=true;
			$(".line5bg").css({"transform":"translate3d(0,0,0)"}) // line5pic
			setTimeout(function(){
				TweenMax.staggerFromTo(".line5pic", 0.5, {
							  cycle:{
								
								opacity:function(i){
									return 0;
									}
							  }
							},
							  
							 {
							  cycle:{
								
								opacity:function(i){
									return 1;
									}
							  }
							  
							,onComplete:function (){
								
								}}, 0.5)
						
				
			},800)
		}		
	}
	
	function quananim(elm){
		var animTop06 = getElemTop(elm);
		
		if(animTop06<winH*0.95 && !elm.play){
			elm.play=true;
			$(".quanBg3").css({transform:"rotate(0)"})
			$(".quanBg2").css({transform:"rotate(0)"})
		}
	}
	
	
	function animfn04(elm){ // 底部文案
		var animTop04 = getElemTop(elm);
		
		if(animTop04<winH*0.5 && !elm.play){
			elm.play=true;
			TweenMax.to(".endtxtpic01",2,{opacity:1,ease:Back.easeOut.config(0),repeat:0,delay:0})
			/*TweenMax.staggerFromTo(".endtxtpic", 0.5, {
						  cycle:{
							
							opacity:function(i){
								return 0;
								},
							y:function(i){
							  return -30;
							}
						  }
						},
						  
						 {
						  cycle:{
							
							opacity:function(i){
								return 1;
								},
							y:function(i){  
							 return 0;
							},
							ease:function (i){
								return  Back.easeOut.config(0); //Back.easeOut.config(10); 缓动 10个像素
								}
						  }
						  
						,onComplete:function (){
							
							}}, 0.5)*/
					
			}		
				
	}
	
	
	function getElemTop(obj) {
	    var rect = obj.getBoundingClientRect();
	    return rect.top;
	}
	
	
	
	})

String.prototype.trim = function () {
    return this.replace(/(^\s*)|(\s*$)/g, "");

}

function checkPhone(phone){ 
	if(!(/^1[3|4|5|6|7|8|9]\d{9}$/.test(phone))){ 
	return false; 
	}else{
		return true;
		} 
}




function setCss3 (obj,attrObj) {
   for (var i in attrObj) {
     var newi=i;
	 if(newi.indexOf("-")>0){
	   var num=newi.indexOf("-");
	   newi=newi.replace(newi.substr(num,2),newi.substr(num+1,1).toUpperCase());
	 }
	 obj.style[newi]=attrObj[i];
	 newi=newi.replace(newi.charAt(0),newi.charAt(0).toUpperCase());
	 obj.style["webkit"+newi]=attrObj[i];
	 obj.style["moz"+newi]=attrObj[i];
	 obj.style["o"+newi]=attrObj[i];
	 obj.style["ms"+newi]=attrObj[i];
   }
  }
